<extend name="Public/base" />

<block name="body">
	<!-- 标题栏 -->
	<div class="main-title">
		<h2>订单列表</h2>
	</div>
	<div class="cf">
		<div class="fl">
			<a class="btn fileDown" href="javascript::">导 出</a>
		</div>
		<div class="search-form fr cf">
			<if condition="IS_ADMIN">
				<div class="btn-group-click adv-sch-pannel fl">
					<label>分类：</label>
		    		<select name="class_id" id="class_id" onchange="changeClass(this);">
		    			<option value="">--请选择--</option>
		    			<volist name="classes" id="v">
		    				<option value="{$v.id}" <if condition="I('class_id') eq $v['id']">selected="selected"</if>>{$v.name}</option>
		    			</volist>
		    		</select>
				</div>
			</if>
			<div class="btn-group-click adv-sch-pannel fl">
				<label>订单状态：</label>
				 <!-- onchange="changeOrder(this);" -->
	    		<select name="take_status" id="take_status" onchange="changeOrder(this);">
	    			<option value="order|-1">--请选择--</option>
	    			<option value="order|0" <if condition="I('status') eq 'order|0'">selected="selected"</if>>等待买家付款</option>
	    			<option value="order|2" <if condition="I('status') eq 'order|2'">selected="selected"</if>>等待发货</option>
	    			<option value="order|3" <if condition="I('status') eq 'order|3'">selected="selected"</if>>已发货</option>
	    			<option value="order|4" <if condition="I('status') eq 'order|4'">selected="selected"</if>>买家确认收货</option>
	    			<option value="return|2" <if condition="I('status') eq 'return|2'">selected="selected"</if>>退款中</option>
	    			<option value="order|6" <if condition="I('status') eq 'order|6'">selected="selected"</if>>成功的订单</option>
	    			<option value="order|5" <if condition="I('status') eq 'order|5'">selected="selected"</if>>关闭的订单</option>
	    		</select>
			</div>
			<div class="btn-group-click adv-sch-pannel fl">
				<div class="row">
				<label>订单时间：</label>
            		<input type="text" id="time-start" name="time-start" class="text input-2x" placeholder="起始时间" value="{:I('time-start')}" /> -      
                    <div class="input-append date" id="datetimepicker"  style="display:inline-block">
                        <input type="text" id="time-end" name="time-end" class="text input-2x" placeholder="结束时间" value="{:I('time-end')}" />
                        <span class="add-on"><i class="icon-th"></i></span>
                    </div>
        		</div>
			</div>
			<div class="sleft">
				<input type="hidden" name="status" id="status">
				<input type="text" name="order_id" class="search-input" value="{:I('order_id')}" placeholder="请输入订单号">
				<a class="sch-btn" href="javascript:;" id="search" url="{:U('Order/index')}"><i class="btn-search"></i></a>
			</div>

            <!-- <div class="btn-group-click adv-sch-pannel fl">
                <button class="btn">高 级<i class="btn-arrowdown"></i></button>
                <div class="dropdown cf">
                	<div class="row">
                		<label>订单时间：</label>
                		<input type="text" id="time-start" name="time-start" class="text input-2x" value="" placeholder="起始时间" value="{:I('time-start')}" /> -      
                        <div class="input-append date" id="datetimepicker"  style="display:inline-block">
                            <input type="text" id="time-end" name="time-end" class="text input-2x" value="" placeholder="结束时间" value="{:I('time-end')}" />
                            <span class="add-on"><i class="icon-th"></i></span>
                        </div>
                	</div>
                </div>
            </div> -->
		</div>
    </div>
    <!-- 数据列表 -->
    <div class="data-table table-striped">
	<table class="">
    <thead>
        <tr>
		<th class="row-selected row-selected"><input class="check-all" type="checkbox"/></th>
		<th class="">序号</th>
		<th class="">订单号</th>
		<th class="">用户ID</th>
		<th class="">实付金额</th>
		<th class="">交易状态</th>
		<th class="">收货状态</th>
		<th class="">退货状态</th>
		<th>订单创建时间</th>
		<th>物流订单</th>
		<th>物流来源</th>
		<th>操作</th>
		</tr>
    </thead>
    <tbody>
		<notempty name="_list">
		<volist name="_list" id="vo">
		<tr>
            <td><input class="ids" type="checkbox" name="id[]" value="{$vo.id}" /></td>
			<td>{$key + 1} </td>
			<td>{$vo.order_id}</td>
			<td>{$vo.client_id}</td>
			<td>￥{$vo.pock_money|default=0}</td>
			<td did="{$vo.order_status}">
				<switch name="vo.order_status">
					<case value="0">等待买家付款</case>
					<case value="1">付款确认中</case>
					<case value="2">买家已付款</case>
					<case value="3">卖家已发货</case>
					<case value="4">交易成功</case>
					<case value="5">交易关闭</case>
					<case value="6">交易完成</case>
				</switch>
			</td>
			<td did="{$vo.take_status}">
				<switch name="vo.take_status">
					<case value="0">---</case>
					<case value="1">未收货</case>
					<case value="2">确认收货</case>
				</switch>
			</td>
			<td did="{$vo.return_status}">
				<a href="{:U('return_index', array('order_id' => $vo['order_id']))}">退货详情<font color="red">({$vo.order_id|getReturnCount=###})</font></a> 
			</td>
			<td>{$vo.ctime|getDateFormat=###}</td>
			<td>{$vo.wl_order|default=''}</td>
			<td>{$vo.wl_name|default=''}</td>
			<td>
				<if condition="$vo.order_status eq 2">
					<!-- <a href="{:U('sendGoods', array('order_id' => $vo['order_id'], 'id' => $vo['id'], 'order_status' => 3))}" class="ajax-get">发货</a> -->
					<a href="{:U('send_detail', array('order_id' => $vo['order_id']))}">发货</a>
				<else />
					<input type="hidden" id="order_{$vo.order_id}" value="{:U('detail', array('order_id' => $vo['order_id']))}">
					<a href="{:U('del', array('order_id' => $vo['order_id']))}" class="ajax-get confirm">删除</a>
					<a href="{:U('send_detail', array('order_id' => $vo['order_id'], 'type' => 'look'))}"">查看详细</a>
					<a href="{:U('bull_address', array('take_id' => $vo['take_id']))}">收货地址</a>
				</if>
            </td>
		</volist>
		<else/>
		<td colspan="13" class="text-center"> aOh! 暂时还没有内容! </td>
		</notempty>
	</tbody>
    </table>
	</div>
    <div class="page">
        {$_page}
    </div>
</block>
<block name="script">
	<link href="__STATIC__/datetimepicker/css/datetimepicker.css" rel="stylesheet" type="text/css">
	<php>if(C('COLOR_STYLE')=='blue_color') echo '<link href="__STATIC__/datetimepicker/css/datetimepicker_blue.css" rel="stylesheet" type="text/css">';</php>
	<link href="__STATIC__/datetimepicker/css/dropdown.css" rel="stylesheet" type="text/css">
	<script type="text/javascript" src="__STATIC__/datetimepicker/js/bootstrap-datetimepicker.min.js"></script>
	<script type="text/javascript" src="__STATIC__/datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js" charset="UTF-8"></script>
	<script src="__STATIC__/thinkbox/jquery.thinkbox.js"></script>

	<script type="text/javascript">
		$(function(){
			//搜索功能
			$("#search").click(function(){
				var url = window.location.href;
				//var status = $("#sch-sort-txt").attr("data");
		        var query  = $('.search-form').find('input').serialize();
		        query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g,'');
		        query = query.replace(/^&/g,'');
			
		        if( url.indexOf('?')>0 ){
		            url += '&' + query;
		        }else{
		            url += '?' + query;
		        }
				window.location.href = url;
			});

			/* 状态搜索子菜单 */
			$(".search-form").find(".drop-down").hover(function(){
				$("#sub-sch-menu").removeClass("hidden");
			},function(){
				$("#sub-sch-menu").addClass("hidden");
			});
			$("#sub-sch-menu li").find("a").each(function(){
				$(this).click(function(){
					var text = $(this).text();
					$("#sch-sort-txt").text(text).attr("data",$(this).attr("value"));
					$("#sub-sch-menu").addClass("hidden");
				})
			});

		    //回车自动提交
		    $('.search-form').find('input').keyup(function(event){
		        if(event.keyCode===13){
		            $("#search").click();
		        }
		    });

		    $('#time-start').datetimepicker({
		        format: 'yyyy-mm-dd',
		        language:"zh-CN",
			    minView:2,
			    autoclose:true
		    });

		    $('#datetimepicker').datetimepicker({
		       format: 'yyyy-mm-dd',
		        language:"zh-CN",
		        minView:2,
		        autoclose:true,
		        pickerPosition:'bottom-left'
		    })

			//导出
			$('.fileDown').click(function(){
				var url = window.location.href,
					take_status = $('#take_status option:selected') .val();//选中的值
			 	if( url.indexOf('?')>0 ){
		            url += '&status=' + take_status + '&show_type=down';
		        }else{
		            url += '?status=' + take_status + '&show_type=down';
		        }
				window.location.href = url;

			});
		});
	
		function changeOrder(obj){
			//$('#status').val(obj.value);
			var url = window.location.href;
			if( url.indexOf('?')>0 ){
				url += '&status=' + obj.value;
			}else{
				url += '?status=' + obj.value;
			}
			window.location.href = url;
		}

		function changeClass(obj){
			var url = window.location.href;
			if( url.indexOf('?')>0 ){
				url += '&class_id=' + obj.value;
			}else{
				url += '?class_id=' + obj.value;
			}
			window.location.href = url;
		}

	    //导航高亮
	    highlight_subnav('{:U('Order/index')}');
	</script>
</block>

